package Ioperation;

import book.BookList;

import java.util.Scanner;

public class Returnoperation implements Ioperation{
    @Override
    public void work(BookList books) {
        int ret = books.getBooksSize();
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入要归还的书名:");
        String name = scanner.nextLine();

        //查找
        for (int i = 0; i < ret; i++) {
            if(name.equals(books.getBooks(i).getName())){
                if(books.getBooks(i).isState()){
                    books.getBooks(i).setState(false);
                    System.out.println("归还成功!");
                    return;
                }else {
                    System.out.println("这本书并未被借出。");
                    return;
                }
            }
        }
        System.out.println("我们没有这本书!");
    }
}
